<?php
$this->title = "A-PMS项目管理系统-修改协同";
//$this->registerCssFile('/css/list/timePicker/jquery-ui-timepicker-addon.css');
//$this->registerCssFile('/css/list/timePicker/jquery-ui-1.11.4.css');
//$this->registerCssFile('/css/officeHall/uploadAssetPackage/initiateSynergy.css');
//$this->registerCssFile('/css/adminLTE/select2.min.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);
//$this->registerCssFile('/css/adminLTE/font-awesome.min.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);
//$this->registerCssFile('/css/adminLTE/daterangepicker.css',['depends'=>'\yii\bootstrap\BootstrapAsset']);
//
//
//$this->registerJsFile('/js/officeHall/uploadAssetPackage/initiateSynergy.js');
//$this->registerJsFile('/css/list/timePicker/jquery-ui-1.11.4.js');
//$this->registerJsFile('/css/list/timePicker/zh-CN.js');
//$this->registerJsFile('/js/adminLTE/bootstrap.min.js');
//$this->registerJsFile('/js/adminLTE/select2.full.min.js');
//$this->registerJsFile('/js/adminLTE/moment.min.js');
//$this->registerJsFile('/js/adminLTE/daterangepicker.js');
//$this->registerJsFile('/css/list/timePicker/jquery-ui-timepicker-addon.js');
//$this->registerJsFile('/css/list/timePicker/jquery-ui-timepicker-zh-CN.js');
?>
<style>
    .liandiv {
        margin-left: -50px;
    }

    .layui-layer-title {
    	color: #fff!important;
    	font-weight: bolder!important;
         font-size: 16px!important;
    }
</style>
<!--//遮罩层-->
<div class="modalFrame show">

</div>
<!--//1.团队组成-->
<div class="container">
    <div class="rwo">
        <div class="mask xy">
            <div class="top">
                <img class="pull-left"
                     src="/image/officeHall/uploadAssetPackage/mask.png"/>
                <span>发起协同</span>
                <img class="pull-right"
                     src="/image/officeHall/uploadAssetPackage/clos.png" alt=""/>
            </div>
            <div class="myFrom">
                <p>1.团队组成</p>
                <form class="formOne">
                    <ul class="formOneUl clearfix">

                        <!--资产包id-->
                        <input type="text" hidden id="package_id"
                               value="<?= \Yii::$app->request->get('packageid', 1); ?>">
                        <!--资产包详情id-->
                        <input type="text" hidden id="package_plan_id"
                               value="<?= !empty($workman['id']) ? $workman['id'] : 0; ?>">
                        <li class="clearfix" style="display: none;">
                            <span class="pull-left"></span>
                            <input type="text" hidden value="<?= !empty($workman['ownerId']) ? $workman['ownerId'] : $ownerName['id']; ?>"
                                   name="uploaded_by_id" class="inputText pull-left" id="uploaded_by_id">
                            <input type="text" hidden list="assetPackageTitle" name="uploaded_by_name" id="uploaded_by_name"
                                   placeholder=""  class="form-control"
                                   value="<?= !empty($workman['description']) ? $workman['description'] . '-' : '' ?><?= !empty($workman['ownerUserName']) ? $workman['ownerUserName'] : $ownerName['realname']; ?>"/>

                            <!--											<button type="button" class="btn  determine btn-success">-->
                            <!--												确定-->
                            <!--											</button>-->
                            <!--											<datalist id="assetPackageTitle">-->
                            <!--												<option value="12提示1"></option>-->
                            <!--												<option value="14提示2"></option>-->
                            <!--												<option value="15提示3"></option>-->
                            <!--											</datalist>-->
                        </li>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <span style="line-height: 30px;color: #888;display: inline-block;font-size: 14px;">上传人</span>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group liandiv">
                                        <select disabled="disabled" style="height: 33px;width:100%;" class="form-control" id="owner" multiple="multiple" data-placeholder="<?= !empty($workman['description']) ? $workman['description'] . '-' : '' ?><?= !empty($workman['ownerUserName']) ? $workman['ownerUserName'] : $ownerName['realname']; ?>" name="realname" style="width: 100%;" >
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                   <span style="line-height: 30px;color: #888;display: inline-block;font-size: 14px;">资产包负责人</span>
                                </div>
                            <div class="col-md-6">
                                <div class="form-group liandiv">
                                    <select class="form-control" id="realname" multiple="multiple" data-placeholder="" name="realname" style="width: 100%;" >
                                        <?php
                                        $leader_idArr = array_filter(explode(',',$leader_id));
                                        if (!empty($leader_idArr)){
                                            foreach ($leader_idArr as $k1 => $v1) {
                                                foreach ($userNameAndID as $k => $v) {
                                                    if ($v1 == $v['id']){
                                                        unset($userNameAndID[$k]);
                                                    }
                                                }
                                            }
                                            foreach ($userNameAndID as $k => $v) {
                                                echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                            }
                                        }else{
                                            foreach ($userNameAndID as $k => $v) {
                                                echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                            }
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <span style="line-height: 30px;color: #888;display: inline-block;font-size: 14px;">预评估</span>
                                </div>
                            <div class="col-md-6">
                                <div class="form-group liandiv">
                                    <select class="form-control select2" multiple="multiple" data-placeholder=""  name="pre_evaluation_name"  style="width: 100%;">
                                        <?php
                                        $pre_evaluationArr = array_filter(explode(',',$pre_evaluation_id));
                                        if (!empty($pre_evaluationArr)){
                                            foreach ($pre_evaluationArr as $k1 => $v1) {
                                                foreach ($userNameAndID as $k => $v) {
                                                    if ($v1 == $v['id']){
                                                        unset($userNameAndID[$k]);
                                                    }
                                                }
                                            }
                                            foreach ($userNameAndID as $k => $v) {
                                                echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                            }
                                        }else{
                                            foreach ($userNameAndID as $k => $v) {
                                                echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                            }
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <span style="line-height: 30px;color: #888;display: inline-block;font-size: 14px;">尽调人员</span>
                                </div>
                        <div class="col-md-6">
                            <div class="form-group liandiv">
                                <select class="form-control select3" multiple="multiple" data-placeholder="" name="due_diligence_name" style="width: 100%;" >
                                    <?php
                                    $due_diligenceArr = array_filter(explode(',', $due_diligence_id));
                                    if (!empty($due_diligenceArr)) {
                                        foreach ($due_diligenceArr as $k1 => $v1) {
                                            foreach ($userNameAndID as $k => $v) {
                                                if ($v1 == $v['id']){
                                                    unset($userNameAndID[$k]);
                                                }
                                            }
                                        }
                                        foreach ($userNameAndID as $k => $v) {
                                            echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>".$v['realname']."</option>";
                                        }
                                    } else {
                                        foreach ($userNameAndID as $k => $v) {
                                            echo "<option DataKeyField='" . $v['id'] . "' value='" . $v['realname'] . "'>" . $v['realname'] . "</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <span style="line-height: 30px;color: #888;display: inline-block;font-size: 14px;">其他说明</span>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group" style="margin-left: -60px;margin-top: -20px;width: 100%;">
                                        <input type="text" placeholder="其他说明" name="other_team_notes" style="    height: 42px;
    border: 2px solid #E2E2E2;
    margin-left: 10px;border-radius:5px;" id="other_team_notes"
                                               class="inputText pull-left"
                                               value="<?= !empty($workman['other_team_notes']) ? $workman['other_team_notes'] : ''; ?>"/>
                                    </div>
                                </div>
                            </div>

            </div>

            </ul>
            </form>

            <div class="lastNextStep">
                <button type="button" class="btn nextStep btn-primary  active pull-right">下一步</button>
                <button type="button" class="btn lastStep pull-right">取&nbsp;&nbsp;消</button>
            </div>

        </div>
    </div>
</div>
</div>

<!--工作计划-->
<?= $this->render('work-plan', [
        'initiationPlan'=>$initiationPlan,
]); ?>

<script>
    var userData = '<?php echo json_encode($userNameAndID);?>';
    // 单击确定
     var JsonToUserData = JSON.parse( userData );
    // console.log(JsonToUserData);
    var UserId = ',';
    var buttonId = '';
    window.onload = function () {
    }
    function delPlan(PlanId) {
        if ($(this).parent().parent().find('li').length == 1 ){
            layer.msg("最后一个禁止删除");
        }else{
            $.post('/package-initiation-plan/del-work-plan',{'workId':PlanId},function (res) {
            })
        }

    }
    $(function () {
        var pre_evaluation_name = JSON.parse('<?= $pre_evaluation_name ?>');
        var pre_evaluation_id = $.grep( '<?= $pre_evaluation_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        var due_diligence_name = JSON.parse('<?= $due_diligence_name ?>');
        var due_diligence_id = $.grep( '<?= $due_diligence_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        var leader_name = JSON.parse('<?= $leader_name ?>');
        var leader_id = $.grep( '<?= $leader_id ?>'.split(','), function(n) {return $.trim(n).length > 0;});
        console.log(pre_evaluation_name);
        //调用关联数据
        $('.select2').select2({
            data: pre_evaluation_name,
        });
        $('.select2').select2({}).val(pre_evaluation_id).trigger('change');
        $('.select3').select2({
            data: due_diligence_name,
        });
        $('.select3').select2({}).val(due_diligence_id).trigger('change');
        $('#realname').select2({
            data: leader_name,
        });
        $('#realname').select2({}).val(leader_id).trigger('change');
        $('#owner').select2({
        });

        //时间
        //Date range picker
        $('.reservation').daterangepicker()
        //Date range picker with time picker
        $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    })
</script>
